<%--
  Created by IntelliJ IDEA.
  User: zll
  Date: 2018/5/30
  Time: 12:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>签到列表</title>

    <jsp:include page="../comm/comm.jsp"/>
</head>
<body>
<div class="layui-form" action="">



</div>
<table id="demo" lay-filter="test"></table>


<script type="text/html" id="operate">
    <button class="layui-btn layui-btn-sm" onclick="modify('{{d.id}}')">详情</button>
</script>
<script type="text/html" id="status">
    {{#  if(d.num < 3){ }}
    <span class="layui-badge">进行中</span>
    {{#  } else { }}
    <span class="layui-badge layui-bg-gray">已完成</span>
    {{#  } }}
</script>

<script>
    function  modifyDate() {
       var startDate=$("#startDate").val();
       var endDate=$("#endDate").val();
       config.commPost("/role/saveDate",{startDate:startDate,endDate:endDate,type:"zhuli"},function (data) {
           alert("成功");
       });
    }
    function  modifytitle() {
        var title=$("#title").val();
        var content=$("#content").val();
        config.commPost("/role/saveZhuli",{title:title,content:content},function (data) {
            alert("成功");
        });
    }


    var type=getQueryString("type");
    var activityId=getQueryString("activityId");
    function modify(id){
        config.openLayer("助力详情","/page/role/listuserzhuli?taskId="+id);


         //location.href="/page/role/listusersigns?openid="+id;
    }
    function deletes(id){
        //eg1
        layer.confirm('确认删除?', {icon: 3, title:'提示'}, function(index){
            config.commPost("/tasks/delete.json",{id:id},function (data) {
                alert("成功");
                location.reload();
            })

            layer.close(index);
        });
    }
    layui.use(['table','laydate'], function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#startDate' //指定元素
        });
        laydate.render({
            elem: '#endDate' //指定元素
        });

        config.commGet("/role/getDates?type=zhuli",{},function (data) {
            $("#startDate").val(data.startDate);
            $("#endDate").val(data.endDate);
        })

        config.commGet("/role/getZhuli",{},function (data) {
            $("#title").val(data.title);
            $("#content").val(data.content);
        })
        var table = layui.table;

        //第一个实例
        table.render({
            elem: '#demo'
            ,url: '/role/zhuliList?activityId='+activityId //数据接口
            ,page: true //开启分页
            ,limits:[10]
            ,response: {
                statusName: 'status' //数据状态的字段名称，默认：code
                ,statusCode: 200 //成功的状态码，默认：0
                ,msgName: 'msg' //状态信息的字段名称，默认：msg
                ,countName: 'msg' //数据总数的字段名称，默认：count
                ,dataName: 'data' //数据列表的字段名称，默认：data
            }
            ,cols: [[ //表头
                {field: 'name', title: '姓名'},
                {field: 'num', title: '助力次数'},
                {field: 'createTime', title: '最近助力时间',templet: '#date'},
                {field: 'createTime', title: '状态',templet: '#status'},
                {field: 'createTime', title: '操作',templet: '#operate'},
            ]]
        });
    });
    function getQueryString(name)
    {
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }
</script>
</body>
</html>
